<template>
        <!-- :maskClosable="isCanCancel"
        :keyboard="isCanCancel"
        :closable="isCanCancel" -->
    <a-modal
        :title="formData.id?'编辑更新记录':'新增更新记录'"
        :visible="visible"
        :confirmLoading="loading"
        :width="800"
        @ok="submit"
        @cancel="$emit('cancel')"
        :destroyOnClose="true"
    >
        <a-spin :spinning="loading">
            <a-form-model ref="form" :model="formData" :label-col="labelCol" :wrapper-col="wrapperCol" :rules="rules">
                <a-form-model-item label="推进事项" prop="promotionMatters">
                    <BaseInput v-model="formData.promotionMatters" placeholder="请输入" />
                </a-form-model-item>
                <a-form-model-item label="推进记录文件上传">
                  <!-- @fileArrysData="cantCancel = false" -->
                    <l-table v-if="visible"
                             :uploadArrys.sync="formData.fileArrays"
                             :businessCode="businessCode"></l-table>
                </a-form-model-item>
            </a-form-model>
        </a-spin>
        
        <!-- <template slot="footer">
          <a-button :disabled="!isCanCancel" key="back" @click="$emit('cancel')">
            取消
          </a-button>
          <a-button key="submit" type="primary" :loading="btnLoading" @click="submit">
            提交
          </a-button>
        </template> -->
    </a-modal>
</template>

<script>
import {
    addUpdateLawmanageProgress,
    editUpdateLawmanageProgress,
    getUpdateProgressDetails, postAdvanceRecord,
    postAdvanceRecordEdit
} from '@/api/legal'

export default {
  name:'a'+Date.now(),
  props: {
        visible: {
            type: Boolean,
            default: () => false
        },
        form: {
            type: Object,
            default: () => {
                return {}
            }
        }
    },
    computed: {
      isCanCancel() {
        return this.cantCancel;
      }
    },
    watch: {
        // 'formData.fileArrays': {
        //   handler(val) {
        //     this.cantCancel = false;
        //   }
        // },
        visible(val) {
            if (val) {
                this.formData = this.$clone(this.form)
            }else {
                this.formData = {}
            }
        }
    },
    data() {
        return {
            cantCancel: true,
            formData: {},
            btnLoading: false,
            loading: false,
            businessCode: 'LCM07',
            labelCol: { span: 3 },
            wrapperCol: { span: 21 },
            rules: {
                outputDescription: [{ required: true, message: '请输入反馈内容', trigger: 'blur' }],
                promotionMatters: [{ required: true, message: '请输入推进事项', trigger: 'blur' }],
                detailedDescription: [{ required: true, message: '请输入主要内容', trigger: 'blur' }]
            }
        }
    },
    methods: {
        /**
         * 更新进展
         **/
        submit() {
            // return  this.$console(this.formData)
            this.$refs.form.validate(async (valid) => {
                if (!valid) return this.$message.warning('信息不完整')
                this.loading = true
                let res
                this.formData.businessCode = 'LCM07'
                this.formData.feedback = []
                if (this.formData.tableId) {
                    res = await postAdvanceRecordEdit(this.formData)
                } else {
                    res = await postAdvanceRecord(this.formData)
                }
                if (res.data.code === 200 || res.code === 200) {
                    this.$message.success('提交成功')
                    this.$emit('ok')
                }
                this.loading = false
            })
        }
    }
}
</script>